problems = function() {
	//添加或修改题目窗体
	var problemAddOrModify = null;
	//添加测试数据窗体
	var problemAddDataWin = null;
	//修改测试数据窗体
	var problemEditDataWin = null;
	//导入测试数据窗体
	var problemImportDataWin = null;
	//搜索题目窗体
	var problemSearchWin = null;
	//定义CKEDITOR
	var problemDescCKEDITOR = null;
	var problemInputCKEDITOR = null;
	var problemOutputCKEDITOR = null;
	var problemSampleInputCKEDITOR = null;
	var problemSampleOutputCKEDITOR = null;
	//上传文件count
	var problemCount = 1;
	//是否要重新加载标志位
	var problemRefreshFlag = false;
	return {
		/*--------------------------------------窗体定义--------------------------------------------*/
		panel: function() {
			//STORE
			var store = new Store({
				fields: ['id', 'number', 'title', 'sclassify', 'sclassifyID', 'difficulty', 'state', 
				         'belong', 'suser', 'ac', 'submit', 'sacDate', 'screateDate', 'supdateDate', 
				         'sorgan', 'auto', 'author', 'source', 'remark', 'timeLimit', 'memoryLimit',
				         'description', 'input', 'output', 'sampleInput', 'sampleOutput', 'hint', 
				         'standardProgram'],
				proxy: {
			        type: 'ajax',
			        url: '../admin/problem.jspx?index',
			        reader: {
			            type: 'json',
			            root: 'datas',
			            totalProperty: 'total'
			        }
			    },
			    autoLoad: false
			});
			//LOAD
			store.removeAll();
			store.currentPage = 1;
			store.proxy.extraParams = {};
			store.load();
			//GRID
			var pageToolBar = Ext.create('Ext.PagingToolbar', {
	            store: store,
	            draggable : false,
	            displayInfo: true
	        });
			var grid = new Grid({
				title: '题目列表',
				id: 'prblemgrid',
				region: 'center',
				store: store,
				minColumnWidth: 35,
				stripeRows: true,
				bbar : pageToolBar,
				tbar: [{
					text: '刷新',
					scale: 'medium',
					iconCls: 'icon-refresh',
					handler: function() {
						problems.refreshProblemAction();
					}
				}, "-", {
					text: '搜索',
					scale: 'medium',
					iconCls: 'icon-search',
					handler: function() {
						problems.searchProblemAction();
					}
				}, "-", {
					text: '添加',
					id: 'problemAdd',
					scale: 'medium',
					iconCls: 'icon-add',
					disabled: true,
					handler: function() {
						problems.addProblemAction();
					}
				}, "-", {
					text: '修改',
					id: 'problemEdit',
					scale: 'medium',
					iconCls: 'icon-edit',
					disabled: true,
					handler: function() {
						problems.editProblemAction();
					}
				}, "-", {
					text: '删除',
					id: 'problemRemove',
					scale: 'medium',
					iconCls: 'icon-remove',
					disabled: true,
					handler: function() {
					}
				}, "-", {
					text: '测试数据',
					id: 'problemData',
					scale: 'medium',
					iconCls: 'icon-data',
					disabled: true,
					handler: function() {
						problems.addDataProblemAction();
					}
				}],
				columns: [
		             new Ext.grid.RowNumberer(),
		             {header: '序号', dataIndex: 'id', hidden: true},
		             {header: '题号', dataIndex: 'number', width: 80},
		             {header: '标题', dataIndex: 'title', width: 200},
		             {header: '分类', dataIndex: 'sclassify', width: 100},
		             {header: '难易度', dataIndex: 'difficulty', width: 100},
		             {header: '判定方式', dataIndex: 'auto', width: 100, renderer: function(v) {
		            	 if (!v) return "正常判定";
		            	 else return "<font color=red>特殊判定</font>";
		             }},
		             {header: '状态', dataIndex: 'state', width: 100, renderer: function(v) {
		            	 switch(v) {
			            	 case 1 : return "已发布";
			            	 case 2 : return "未发布";
			            	 case 3 : return "无数据";
		            	 }
		             }},
		             {header: '发布范围', dataIndex: 'belong', width: 100, renderer: function(v) {
		            	 switch(v) {
			            	 case 0 : return "全局共享";
			            	 case 1 : return "局部共享";
		            	 }
		             }},
		             {header: '创建者', dataIndex: 'suser', width: 100},
		             {header: '通过次数', dataIndex: 'ac', width: 100},
		             {header: '提交次数', dataIndex: 'submit', width: 100},
		             {header: '最后通过时间', dataIndex: 'sacDate', width: 150},
		             {header: '更新时间', dataIndex: 'supdateDate', width: 150},
		             {header: '创建时间', dataIndex: 'screateDate', width: 150},
		             {header: '所属组织', dataIndex: 'sorgan', width: 150}
				]
			});
			
			var panel = new Panel({
				layout: 'border',
				border: false,
				items: [grid]
			});
			return panel;
		},
		//添加或修改窗体
		addOrEdit: function(obj) {
			if (problemAddOrModify == null) {
				//必选项标志
				var required = '<span style="color:red;font-weight:bold" data-qtip="Required">*</span>';
				
				var classifystore = new Store({
					fields: ['id', 'name'],
					proxy: {
				        type: 'ajax',
				        url: '../admin/problem.jspx?indexOFtype'
					},
					autoLoad: true
				});
				
				var autostore = new Store({
					fields: ['str', 'val'],
					data: [{
						str: '正常判定', val: false
					}, {
						str: '特殊判定', val: true
					}]
				});
				
				var belongstore = new Store({
					fields: ['str', 'val'],
					data: [{
						str: '全局共享', val: 0
					}, {
						str: '范围共享', val: 1
					}]
				});
				
				var statestore = new Store({
					fields: ['str', 'val'],
					data: [{
						str: '已发布', val: 1
					}, {
						str: '未发布', val: 2
					}, {
						str: '无数据', val: 3
					}]
				});
				
				//题号STORE
				var numberstore = new Store({
					fields: ['id', 'title', 'number'],
					proxy: {
				        type: 'ajax',
				        url: '../admin/problem.jspx?indexOFnumber',
				        reader: {
				            type: 'json',
				            root: 'datas',
				            totalProperty: 'total'
				        }
				    },
				    pageSize: 20
				});
				
				problemAddOrModify = new Window({
				    title: '题目信息编辑',
				    height: 550,
				    width: 900,
				    layout: 'fit',
				    closeAction: "hide",
				    modal: true,
				    items: [{
				    	xtype: 'form',
				    	id: 'problemAddOrModifyForm',
				    	frame: false,
						autoHeight: true,
						bodyPadding: 15,
						autoScroll: true,
						fieldDefaults: {
				            labelWidth: 75
				        },
				        defaultType: 'textfield',
				        defaults: {
				            anchor: '100%'
				        },
				        items: [{
				        	name: 'id',
				        	hidden: true
				        }, {
			                xtype: 'fieldset',
			                title: '基本信息',
			                defaultType: 'textfield',
			                layout: 'hbox',
			                defaults: {
			                    anchor: '100%'
			                },
			                items: [{
			                    xtype: 'fieldcontainer',
			                    layout: 'anchor',
			                    flex: 1,
			                    defaultType: 'textfield',
			                    defaults: {
			                    	labelWidth: 75,
			                    	anchor: '100%'
			                    },
			                    items: [{
			                    	xtype: 'combo',
									fieldLabel: '题号',
									name: 'number',
									store: numberstore,
									displayField: 'number',
									typeAhead: false,
									hideTrigger:true,
									allowBlank: false,
			                    	afterLabelTextTpl: required,
									regex : /^[1-9]\d*$/,
									listConfig: {
										loadingText: '查找中...',
										emptyText: '找不到相对应的题号！',
										getInnerTpl: function() {
											return '<h3>{number}&nbsp;&nbsp;&nbsp;{title}</h3>';
										}
									},
									pageSize: 10
								}, {
			                    	name: 'title',
			                    	fieldLabel: '标题',
			                    	allowBlank: false,
			                    	afterLabelTextTpl: required
			                    }, {
			                    	xtype: 'combo',
			                    	name: 'sclassifyID',
			                    	fieldLabel: '分类',
			                    	allowBlank: false,
			                    	afterLabelTextTpl: required,
			                    	store: classifystore,
			                    	displayField: 'name',
			                        valueField: 'id',
			                        queryMode: 'local',
			                        editable: false
			                    }, {
			                    	name: 'author',
			                    	fieldLabel: '作者'
			                    }, {
			                    	name: 'source',
			                    	fieldLabel: '来源'
			                    }, {
			                    	xtype: 'textareafield',
			                    	name: 'remark',
			                    	fieldLabel: '备注说明'
			                    }] 
			                }, {
			                    xtype: 'fieldcontainer',
			                    layout: 'anchor',
			                    flex: 1,
			                    defaultType: 'textfield',
			                    defaults: {
			                    	labelWidth: 75,
			                    	anchor: '100%'
			                    },
			                    items: [{
			                    	xtype: 'numberfield',
			                    	name: 'timeLimit',
			                    	fieldLabel: '时间限制',
			                    	allowBlank: false,
			                    	value: 1000,
			                    	afterLabelTextTpl: required,
			                    	regex : /^[1-9]\d*$/
			                    }, {
			                    	xtype: 'numberfield',
			                    	name: 'memoryLimit',
			                    	fieldLabel: '内存限制',
			                    	allowBlank: false,
			                    	value: 32768,
			                    	afterLabelTextTpl: required,
			                    	regex : /^[1-9]\d*$/
			                    }, {
			                    	xtype: 'numberfield',
			                    	name: 'difficulty',
			                    	fieldLabel: '难易度',
			                    	allowBlank: false,
			                    	afterLabelTextTpl: required,
			                    	value: 1,
			                    	minValue: 1,
			                    	maxValue: 10,
			                    	regex : /^[1-9]\d*$/
			                    }, {
			                    	xtype: 'combo',
			                    	name: 'auto',
			                    	fieldLabel: '判定方式',
			                    	allowBlank: false,
			                    	afterLabelTextTpl: required,
			                    	store: autostore,
			                    	displayField: 'str',
			                        valueField: 'val',
			                        queryMode: 'local',
			                        editable: false
			                    }, {
			                    	xtype: 'combo',
			                    	name: 'belong',
			                    	fieldLabel: '发布范围',
			                    	allowBlank: false,
			                    	afterLabelTextTpl: required,
			                    	store: belongstore,
			                    	displayField: 'str',
			                        valueField: 'val',
			                        queryMode: 'local',
			                        editable: false
			                    }, {
			                    	xtype: 'combo',
			                    	name: 'state',
			                    	fieldLabel: '状态',
			                    	allowBlank: false,
			                    	afterLabelTextTpl: required,
			                    	store: statestore,
			                    	displayField: 'str',
			                        valueField: 'val',
			                        queryMode: 'local',
			                        editable: false,
			                        listeners: {
			                        	select: function(fn, records, eOpts) {
			                        		if (obj.get('state') != 3 && records[0].get('val') == 3) {
			                        			Ext.Show.msg('温馨提示', '若继续选为无数据，则会删除相应的测试数据！');
			                        		}
			                        	}
			                        }
			                    }] 
			                }] 
			            }, {
			                xtype: 'fieldset',
			                title: '详细内容',
			                defaultType: 'textfield',
			                layout: 'anchor',
			                defaults: {
			                    anchor: '100%'
			                },
			                items:[{
				        		xtype: 'fieldcontainer',
				                fieldLabel: '题目描述',
				                layout: 'fit',
				                height: 330,
				                items: [{
				        	    	xtype: 'panel',
				        	    	border: false,
				        	    	html: '<textarea id="problemDescription" name="description"></textarea>',
				        	    	height: 330
				        		}, {
				        			xtype: 'textareafield',
				        			name: 'description',
				        			hidden: true
				        		}]
				        	}, {
				        		xtype: 'fieldcontainer',
				                fieldLabel: '题目输入',
				                layout: 'fit',
				                height: 330,
				                items: [{
				        	    	xtype: 'panel',
				        	    	border: false,
				        	    	html: '<textarea id="problemInput" name="input"></textarea>',
				        	    	height: 330
				        		}, {
				        			xtype: 'textareafield',
				        			name: 'input',
				        			hidden: true
				        		}]
				        	}, {
				        		xtype: 'fieldcontainer',
				                fieldLabel: '题目输出',
				                layout: 'fit',
				                height: 330,
				                items: [{
				        	    	xtype: 'panel',
				        	    	border: false,
				        	    	html: '<textarea id="problemOutput" name="output"></textarea>',
				        	    	height: 330
				        		}, {
				        			xtype: 'textareafield',
				        			name: 'output',
				        			hidden: true
				        		}]
				        	}, {
				        		xtype: 'fieldcontainer',
				                fieldLabel: '标准输入',
				                layout: 'fit',
				                height: 330,
				                items: [{
				        	    	xtype: 'panel',
				        	    	border: false,
				        	    	html: '<textarea id="problemSampleInput" name="sampleInput"></textarea>',
				        	    	height: 330
				        		}, {
				        			xtype: 'textareafield',
				        			name: 'sampleInput',
				        			hidden: true
				        		}]
				        	}, {
				        		xtype: 'fieldcontainer',
				                fieldLabel: '标准输出',
				                layout: 'fit',
				                height: 330,
				                items: [{
				        	    	xtype: 'panel',
				        	    	border: false,
				        	    	html: '<textarea id="problemSampleOutput" name="sampleOutput"></textarea>',
				        	    	height: 330
				        		}, {
				        			xtype: 'textareafield',
				        			name: 'sampleOutput',
				        			hidden: true
				        		}]
				        	},
//				        	, {
//				        		xtype: 'textareafield',
//				        		fieldLabel: '标准输入',
//				        		name: 'sampleInput',
//				        		height: 200
//				        	}, 
//				        	{
//				        		xtype: 'textareafield',
//				        		fieldLabel: '标准输出',
//				        		name: 'sampleOutput',
//				        		height: 200
//				        	}, 
				        	{
				        		xtype: 'textareafield',
				        		fieldLabel: '题目提示',
				        		name: 'hint',
				        		height: 200
				        	}, {
				        		xtype: 'textareafield',
				        		fieldLabel: '标准程序',
				        		name: 'standardProgram',
				        		height: 200
				        	}] 
			            }],
			            buttons: [{
			            	text: '确定',
			            	handler: function() {
			            		var fom = Ext.getCmp('problemAddOrModifyForm').getForm();
				        		if (fom.isValid()) {
				        			fom.findField('description').setValue(problemDescCKEDITOR.getData());
				        			fom.findField('input').setValue(problemInputCKEDITOR.getData());
				        			fom.findField('output').setValue(problemOutputCKEDITOR.getData());
				        			fom.findField('sampleInput').setValue(problemSampleInputCKEDITOR.getData());
				        			fom.findField('sampleOutput').setValue(problemSampleOutputCKEDITOR.getData());
				        			problems.formSubmitAction(fom);
				        		}
			            	}
			            }, {
			            	text: '取消',
			            	handler: function() {
			            		problemAddOrModify.hide();
			            	}
			            }]
				    }],
				    listeners: {
				    	afterrender: function(fn, eOpts) {
				    		problemDescCKEDITOR = CKEDITOR.replace('problemDescription');
				    		problemInputCKEDITOR = CKEDITOR.replace('problemInput');
				    		problemOutputCKEDITOR = CKEDITOR.replace('problemOutput');
				    		problemSampleInputCKEDITOR = CKEDITOR.replace('problemSampleInput');
				    		problemSampleOutputCKEDITOR = CKEDITOR.replace('problemSampleOutput');
				    	},
				    	beforedestroy: function(fn, eOpts) {
				    		problemDescCKEDITOR.destroy();
				    		problemInputCKEDITOR.destroy();
				    		problemOutputCKEDITOR.destroy();
				    		problemSampleInputCKEDITOR.destroy();
				    		problemSampleOutputCKEDITOR.destroy();
				    	},
			        	hide: function(fn, eOpts) {
			        		Ext.getCmp('problemAddOrModifyForm').getForm().reset();
			        	}
				    }
				});
			}
			problemAddOrModify.show();
			if (obj != undefined) {
				problemDescCKEDITOR.setData(obj.get('description'));
				problemInputCKEDITOR.setData(obj.get('input'));
				problemOutputCKEDITOR.setData(obj.get('output'));
				problemSampleInputCKEDITOR.setData(obj.get('sampleInput'));
				problemSampleOutputCKEDITOR.setData(obj.get('sampleOutput'));
			} else {
				problemDescCKEDITOR.setData('');
				problemInputCKEDITOR.setData('');
				problemOutputCKEDITOR.setData('');
				problemSampleInputCKEDITOR.setData('');
				problemSampleOutputCKEDITOR.setData('');
			}
		},
		//添加测试数据窗体
		addDataWin: function(sel) {
			if (problemAddDataWin == null) {
				//数据STORE
				var store = new Store({
					fields: ['name', 'size', 'date'],
					proxy: {
				        type: 'ajax',
				        url: '../admin/problem.jspx?dataOFfile'
				    },
				    sorters: [
				       {
		                  property : 'name',
		                  direction: 'asc'
				       },
				    ],
				    autoLoad: false
				});
				
				problemAddDataWin = new Window({
				    title: '测试数据',
				    height: 500,
				    width: 950,
				    layout: 'border',
				    closeAction: "hide",
				    modal: true,
				    
				    items: [{
				    	xtype: 'form',
				    	id: 'problemAddDataForm',
				    	title: '上传测试数据',
				    	region: 'center',
				    	frame: false,
						autoHeight: true,
						bodyPadding: 15,
						overflowY: 'scroll',
				        defaults: {
				            anchor: '97%'
				        },
				        layout: 'anchor',
				        tbar: [{
					    	text: '添加',
					    	scale: 'medium',
					    	iconCls: 'icon-add',
					    	handler: function() {
					    		problems.addFileFieldAction();
					    	}
					    }, "-", {
					    	text: '上传',
					    	scale: 'medium',
					    	iconCls: 'icon-upload',
					    	handler: function() {
					    		problems.uploadDataAction();
					    	}
					    }, "-", {
					    	text: '导入(zip)',
					    	scale: 'medium',
					    	iconCls: 'icon-its',
					    	handler: function() {
					    		problems.importDataAction();
					    	}
					    }],
				        items: []
				    }, {
				    	xtype: 'grid',
				    	id: 'problemDataGrid',
				    	title: '已上传的测试数据',
				    	region: 'east',
				    	width: '50%',
						store: store,
						minColumnWidth: 35,
						stripeRows: true,
						tbar: [{
							text: '修改',
							scale: 'medium',
							iconCls: 'icon-edit',
							handler: function() {
								problems.editDataAction();
							}
						}, "-", {
							text: '删除',
							scale: 'medium',
							iconCls: 'icon-remove',
							handler: function() {
								problems.removeDataAction();
							}
						}],
						columns: [
				             new Ext.grid.RowNumberer(),
				             {header: '数据名称', dataIndex: 'name', width: 120},
				             {header: '文件长度', dataIndex: 'size', width: 120},
				             {header: '修改时间', dataIndex: 'date', width: 150}
						]
				    }],
				    buttons: [{
				    	text: '取消',
				    	handler: function() {
				    		problemAddDataWin.hide();
				    	}
				    }],
			        listeners: {
			        	hide: function(fn, eOpts) {
			        		problems.initDataFormAction();
			        		if (problemRefreshFlag) {
			        			Ext.getCmp('prblemgrid').getStore().load();
			        			problemRefreshFlag = false;
			        		}
			        	}
			        }
				});
				problems.addFileFieldAction();
			}
			problemAddDataWin.show();
		},
		//修改测试数据窗体
		editDataWin: function() {
			if (problemEditDataWin == null) {
				problemEditDataWin = new Window({
				    title: '测试数据编辑',
				    height: 550,
				    width: 650,
				    layout: 'border',
				    closeAction: "hide",
				    modal: true,
				    items: [{
				    	xtype: 'form',
				    	id: 'problemEditDataForm',
				    	region: 'center',
				    	frame: false,
						autoHeight: true,
						bodyPadding: 15,
				        layout: 'fit',
				        items: [{
				        	xtype: 'textfield',
				        	name: 'name',
				        	hidden: true
				        }, {
				        	xtype: 'textareafield',
				        	name: 'content'
				        }],
				        buttons: [{
				        	text: '确定',
				        	handler: function() {
				        		problems.saveDataAction();
				        	}
				        }, {
				        	text: '取消',
				        	handler: function() {
				        		problemEditDataWin.hide();
				        	}
				        }]
				    }]
				});
			}
			problemEditDataWin.show();
		},
		//导入测试数据窗体
		ImportDataWin: function() {
			if (problemImportDataWin == null) {
				problemImportDataWin = new Window({
				    title: '导入测试数据',
				    height: 120,
				    width: 450,
				    layout: 'border',
				    closeAction: "hide",
				    modal: true,
				    items: [{
				    	xtype: 'form',
				    	id: 'problemImportDataForm',
				    	region: 'center',
				    	frame: false,
						autoHeight: true,
						bodyPadding: 15,
				        layout: 'hbox',
				        items: [{
					    	xtype: 'filefield',
					    	flex: 1,
					    	name: 'file',
					    	labelWidth: 75,
					    	fieldLabel: '测试数据包',
					    	buttonText: '选择(zip)',
					    	allowBlank: false,
					    	listeners: {
					    		change: function(fn, val, eOpts) {
				        			var str = val.substring(val.indexOf('.') + 1);
				        			if (str.toLowerCase() != 'zip') {
				        				Ext.Msg.alert('提示', '请选择扩展名为zip的文件！');
				        				this.setRawValue('');
				        			}
				        		}
					    	}
					    }],
					    buttons: [{
					    	text: '确定',
					    	handler: function() {
					    		var fom = this.up('form').getForm();
					    		if (fom.isValid()) {
					    			problems.importDataSubmitAction(fom);
					    		}
					    	}
					    }, {
					    	text: '取消',
					    	handler: function() {
					    		problemImportDataWin.hide();
					    	}
					    }]
				    }],
				    listeners: {
				    	hide: function(fn, eOpts) {
				    		Ext.getCmp('problemImportDataForm').getForm().reset();
				    	}
				    }
				});
			}
			problemImportDataWin.show();
		},
		//搜索题目窗体
		searchProblemWin: function() {
			if (problemSearchWin == null) {
				var classifystore = new Store({
					fields: ['id', 'name'],
					proxy: {
				        type: 'ajax',
				        url: '../admin/problem.jspx?indexOFalltype'
					},
					autoLoad: true
				});
				
				var autostore = new Store({
					fields: ['str', 'val'],
					data: [{
						str: '全部', val: -1
					}, {
						str: '正常判定', val: 0
					}, {
						str: '特殊判定', val: 1
					}]
				});
				
				var belongstore = new Store({
					fields: ['str', 'val'],
					data: [{
						str: '全部', val: -1
					} ,{
						str: '全局共享', val: 0
					}, {
						str: '范围共享', val: 1
					}]
				});
				
				var statestore = new Store({
					fields: ['str', 'val'],
					data: [{
						str: '全部', val: -1
					}, {
						str: '已发布', val: 1
					}, {
						str: '未发布', val: 2
					}, {
						str: '无数据', val: 3
					}]
				});
				
				problemSearchWin = new Window({
				    title: '搜索题目',
				    height: 250,
				    width: 450,
				    layout: 'fit',
				    closeAction: "hide",
				    modal: true,
				    items: [{
				    	xtype: 'form',
				    	id: 'problemSearchForm',
				    	frame: false,
						autoHeight: true,
						bodyPadding: 15,
				        defaults: {
				            anchor: '100%',
				            labelWidth: 75
				        },
				        layout: 'anchor',
				        items: [{
				        	xtype: 'textfield',
				        	name: 'number',
				        	fieldLabel: '题号'
				        }, {
				        	xtype: 'textfield',
				        	name: 'title',
				        	fieldLabel: '标题'
				        }, {
				        	xtype: 'combo',
	                    	name: 'sclassifyID',
	                    	fieldLabel: '题目分类',
	                    	store: classifystore,
	                    	displayField: 'name',
	                        valueField: 'id',
	                        queryMode: 'local',
	                        editable: false,
	                        value: -1
				        }, {
				        	xtype: 'combo',
	                    	name: 'auto',
	                    	fieldLabel: '判定方式',
	                    	store: autostore,
	                    	displayField: 'str',
	                        valueField: 'val',
	                        queryMode: 'local',
	                        editable: false,
	                        value: -1
				        }, {
				        	xtype: 'combo',
	                    	name: 'belong',
	                    	fieldLabel: '发布范围',
	                    	store: belongstore,
	                    	displayField: 'str',
	                        valueField: 'val',
	                        queryMode: 'local',
	                        editable: false,
	                        value: -1
				        }],
				        buttons: [{
				        	text: '确定',
				        	handler: function() {
				        		problems.searchProblemSureAction();
				        	}
				        }, {
				        	text: '取消',
				        	handler: function() {
				        		problemSearchWin.hide();
				        	}
				        }]
				    }],
				    listeners: {
				    	hide: function(fn, eOpts) {
				    		Ext.getCmp('problemSearchForm').getForm().reset();
				    	}
				    }
				});
			}
			problemSearchWin.show();
		},
		/*--------------------------------------触发事件定义--------------------------------------------*/
		//刷新触发事件
		refreshProblemAction: function() {
			Ext.getCmp('prblemgrid').getStore().load();
		},
		//添加触发事件
		addProblemAction: function() {
			problems.addOrEdit();
			var fom = Ext.getCmp('problemAddOrModifyForm').getForm();
			fom.findField('state').setValue(3);
			fom.findField('state').setReadOnly(true);
		},
		//修改触发事件
		editProblemAction: function() {
			var sel = Ext.getCmp('prblemgrid').getSelectionModel().getSelection();
			if (sel.length < 1) {
				Ext.Msg.alert('提示', '请选择要修改的题目！');
			} else {
				problems.addOrEdit(sel[0]);
				var fom = Ext.getCmp('problemAddOrModifyForm').getForm();
				if (sel[0].get('state') == 3) {
					fom.findField('state').setReadOnly(true);
				} else {
					fom.findField('state').setReadOnly(false);
				}
				fom.loadRecord(sel[0]);
			}
		},
		//表单提交事件
		formSubmitAction: function(fom) {
			var url = '../admin/problem.jspx?edit';
			var id = fom.findField('id').value;
			if (id == '') {
				url = '../admin/problem.jspx?add';
			}
			var res = FormSubmit(fom, url, {}, function(obj) {
				if (obj.success) {
					Ext.getCmp('prblemgrid').getStore().load();
					problemAddOrModify.hide();
				}
			});
		},
		//添加测试数据
		addDataProblemAction: function() {
			var sel = Ext.getCmp('prblemgrid').getSelectionModel().getSelection();
			if (sel.length < 1) {
				Ext.Msg.alert('提示', '请选择要测试数据管理的题目！');
			} else {
				problems.addDataWin();
				Ext.getCmp('problemDataGrid').getStore().load({
					params: {
						id: sel[0].get('id')
					}
				});
			}
		},
		//添加上传测试数据
		addFileFieldAction: function() {//problemCount
			var fom = Ext.getCmp('problemAddDataForm');
			//添加上传组件
			fom.add({
				xtype: 'fieldcontainer',
				name: 'file' + problemCount,
				defaults: {
		            anchor: '100%'
		        },
		        layout: 'anchor',
	        	fieldLabel: '测试数据',
	        	labelWidth: 75,
	        	items: [{
		        	xtype: 'fieldcontainer',
		        	layout: 'hbox',
		        	items: [{
		        		xtype: 'filefield',
		        		name: 'file',
			        	//name: 'fileIn_' + problemCount,
			        	flex: 1,
			        	allowBlank: false,
			        	buttonText: '选择(in)',
			        	buttonConfig: {
			        		width: 75
			        	},
			        	listeners: {
			        		change: function(fn, val, eOpts) {
			        			var str = val.substring(val.indexOf('.') + 1);
			        			if (str.toLowerCase() != 'in') {
			        				Ext.Msg.alert('提示', '请选择扩展名为in的文件！');
			        				this.setRawValue('');
			        			}
			        		}
			        	}
			        }, {
			        	xtype: 'button',
			        	text: '删除数据',
			        	style: 'margin-left: 5px',
			        	handler: function() {
			        		fom.remove(this.up('fieldcontainer').up('fieldcontainer'), true);
			        	}
			        }]
		        }, {
		        	xtype: 'fieldcontainer',
		        	layout: 'hbox',
		        	items: [{
		        		xtype: 'filefield',
		        		name: 'file',
		        		flex: 1,
		        		allowBlank: false,
			        	buttonText: '选择(out)',
			        	buttonConfig: {
			        		width: 75
			        	},
			        	listeners: {
			        		change: function(fn, val, eOpts) {
			        			var str = val.substring(val.indexOf('.') + 1);
			        			if (str.toLowerCase() != 'out') {
			        				Ext.Msg.alert('提示', '请选择扩展名为out的文件！');
			        				this.setRawValue('');
			        			}
			        		}
			        	}
			        }, {
		        		xtype: 'component',
		        		width: 67
		        	}]
		        }]
			});
			problemCount++;
		},
		//上传测试数据事件
		uploadDataAction: function() {
			var fomPanel = Ext.getCmp('problemAddDataForm');
			var fom = fomPanel.getForm();
			if (!fom.isValid() || fomPanel.items.items.length < 1) {
				return false;
			}
			var sel = Ext.getCmp('prblemgrid').getSelectionModel().getSelection();
			var res = FormSubmit(fom, '../admin/problem.jspx?data', { id : sel[0].get('id') }, function(obj) {
//				if (obj.success) {
					problemRefreshFlag = true;
					Ext.getCmp('problemDataGrid').getStore().load({
						params: {
							id: sel[0].get('id')
						}
					});
					//还原
					problems.initDataFormAction();
//				}
			});
		},
		//初始化上传组件
		initDataFormAction: function() {
			Ext.getCmp('problemAddDataForm').removeAll();
			problemCount = 1;
    		problems.addFileFieldAction();
		},
		//删除测试数据事件
		removeDataAction: function() {
			var rec = Ext.getCmp('prblemgrid').getSelectionModel().getSelection();
			var sel = Ext.getCmp('problemDataGrid').getSelectionModel().getSelection();
			if (sel.length < 1) {
				Ext.Msg.alert('提示', '请选择要删除的测试数据！');
			} else {
				Ext.MessageBox.confirm('确认', '您确认要删除该测试数据吗？', function(btn) {
					if (btn == "yes") {
						var res = RequestByUrl('../admin/problem.jspx?dataOFremove', {
							id: rec[0].get('id'),
							dataId: sel[0].get('name')
						});
						if (res.success) {
							problemRefreshFlag = true;
							Ext.getCmp('problemDataGrid').getStore().load({
								params: {
									id: rec[0].get('id')
								}
							});
							Ext.Show.msg(res.title, '');
						}
					}
				});
			}
		},
		//修改测试数据事件
		editDataAction: function() {
			var rec = Ext.getCmp('prblemgrid').getSelectionModel().getSelection();
			var sel = Ext.getCmp('problemDataGrid').getSelectionModel().getSelection();
			if (sel.length < 1) {
				Ext.Msg.alert('提示', '请选择要修改的测试数据！');
			} else {
				var res = RequestByUrl('../admin/problem.jspx?dataOFdetail', {
					id: rec[0].get('id'),
					name: sel[0].get('name')
				});
				problems.editDataWin();
				var fom = Ext.getCmp('problemEditDataForm').getForm();
				fom.findField('name').setValue(sel[0].get('name'));
				fom.findField('content').setValue(res.content);
			}
		},
		//修改测试数据保存事件
		saveDataAction: function() {
			var rec = Ext.getCmp('prblemgrid').getSelectionModel().getSelection();
			var fom = Ext.getCmp('problemEditDataForm').getForm();
			var res = FormSubmit(fom, '../admin/problem.jspx?dataOFsave', { id : rec[0].get('id') }, function(obj) {
				if (obj.success) {
					Ext.getCmp('problemDataGrid').getStore().load({
						params: {
							id: rec[0].get('id')
						}
					});
					problemEditDataWin.hide();
				}
			});
		},
		//导入测试数据窗体
		importDataAction: function() {
			problems.ImportDataWin();
		},
		//导入测试数据提交事件
		importDataSubmitAction: function(fom) {
			var sel = Ext.getCmp('prblemgrid').getSelectionModel().getSelection();
			var res = FormSubmit(fom, '../admin/problem.jspx?dataOFrar', { id : sel[0].get('id') }, function(obj) {
				if (obj.success) {
					problemRefreshFlag = true;
					Ext.getCmp('problemDataGrid').getStore().load({
						params: {
							id: sel[0].get('id')
						}
					});
					problemImportDataWin.hide();
				}
			});
		},
		//搜索题目事件
		searchProblemAction: function() {
			problems.searchProblemWin();
		},
		//搜索题目确定事件
		searchProblemSureAction: function() {
			var fom = Ext.getCmp('problemSearchForm').getForm();
			var store = Ext.getCmp('prblemgrid').getStore();
			store.removeAll();
			store.currentPage = 1;
			var auto = fom.findField('auto').value;
			if (auto == 0) auto = 'false';
			else if (auto == 1) auto = 'true';
			store.proxy.extraParams = {
					number: fom.findField('number').value,
					title: fom.findField('title').value,
					belong: fom.findField('belong').value,
					sclassifyID: fom.findField('sclassifyID').value,
					auto: auto
			};
			store.load();
			problemSearchWin.hide();
		}
	};
}();